package com.bw.seckill_module;

import com.blankj.utilcode.util.ApiUtils;
import com.bw.common.mvvm.model.BaseRespository;
import com.bw.network_sdk.BaseEntity;
import com.bw.network_sdk.HttpType;
import com.bw.network_sdk.NetWorkFactory;
import com.bw.seckill_module.api.ApiService;
import com.bw.seckill_module.entity.SecKillEntity;
import com.bw.seckill_module.entity.SecKillListEntity;

import java.util.Map;

import io.reactivex.Observable;

public class SecKillRespository extends BaseRespository {

    //获取列表
    public Observable<BaseEntity>requestSecKillList(){
        Observable<SecKillListEntity>secKillListEntityObservable =
                NetWorkFactory.factory(HttpType.TOKEN)
                        .create(ApiService.class)
                        .requestSeckillList();
        return checkNetWork(secKillListEntityObservable);
    }
    //发起秒杀
    public Observable<BaseEntity>requestSecKill(Map<String,Object>map){
        Observable<SecKillEntity>secKillEntityObservable =
                NetWorkFactory.factory(HttpType.TOKEN)
                        .create(ApiService.class)
                        .requestSeckill(createBody(map));
        return checkNetWork(secKillEntityObservable);
    }
}
